
import java.util.Stack;
class Test {

    Stack<Integer> stack1=new Stack<>();
    Stack<Integer> stack2=new Stack<>();
    public Test() {
        stack1=new Stack<>();
        stack2=new Stack<>();
    }
    public void push(int val) {

        stack1.add(val);
        if (stack2.empty()) {
            stack2.add(val);
        } else {
            if (stack2.peek()>=val) {
                stack2.add(val);
            }

        }
    }
    public void pop() {
        if (stack1.pop().equals(stack2.peek())) {
            stack2.pop();
        }
    }
    public int top() {
        return stack1.peek();
    }
    public int getMin() {
        return stack2.peek();

    }

    public static void main(String[] args) {
    //["MinStack","push","push","push","getMin","top","pop","getMin"]
    Test test=new Test();
    test.push(0);
    test.push(1);
        System.out.println(test.top());
        //3 5 5
        System.out.println(test.getMin());
        test.pop();
        int c=test.getMin();
        System.out.println(c);
        System.out.println(test.top());
    }

}